<template>
    <div id="container">
        <div id="histogram" style="height: 250px;"></div>
    </div>
</template>

<script>
    import * as echarts from "echarts";
    export default {
        name: "LineGram",
        props:{
            /*图例类型注入*/
            data:[],
            /*图数据注入*/
            series:[]
        },
        mounted() {
            this.initLine()
        },
        methods:{
            initLine(){
                let option = {
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {            // Use axis to trigger tooltip
                            type: 'shadow'        // 'shadow' as default; can also be 'line' or 'shadow'
                        }
                    },
                    legend: {
                        data: ['优化前', '优化后']
                    },
                    grid: {
                        left: '2%',
                        right: '2%',
                        bottom: '2%',
                        containLabel: true
                    },
                    xAxis: {
                        type: 'category',
                        data: ['中子', '转子', '轴承', '发电机', '叶片', '风轮轴', '主机架']
                    },
                    yAxis: {
                        type: 'value'
                    },
                    series: [
                        {
                            name: '优化前',
                            type: 'bar',
                            stack: 'total',
                            label: {
                                show: true
                            },
                            emphasis: {
                                focus: 'series'
                            },
                            data: [320, 302, 301, 334, 390, 330, 320]
                        },
                        {
                            name: '优化后',
                            type: 'bar',
                            stack: 'total',
                            label: {
                                show: true
                            },
                            emphasis: {
                                focus: 'series'
                            },
                            data: [120, 132, 101, 134, 90, 230, 210]
                        },
                    ]
                };
                let mychart = echarts.init(document.getElementById('histogram'));
                mychart.setOption(option)
            }
        }
    }
</script>

<style scoped>

</style>
